<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>明星展示页面</title>
    <!-- Bootstrap core CSS -->
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link th:href="@{/css/dashboard.css}" rel="stylesheet">
    <style type="text/css">
        /* Chart.js */

        @-webkit-keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        @keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        .chartjs-render-monitor {
            -webkit-animation: chartjs-render-animation 0.001s;
            animation: chartjs-render-animation 0.001s;
        }
    </style>
</head>
<style>
    .box {
        width: 100%;
        height: 100%;
        text-align: justify;
    }
    .box:after {
        content: "";
        display: inline-block;
        overflow: hidden;
        width: 100%;
    }

    .box span {
        width: 50px;
        height: 20px;
        display: inline-block;
        text-align: center;
        line-height: 5px;
    }
</style>
<body>
<div>
    <!--侧边栏,抽取出来，可以插进去th:fragment="sidebar"-->
        <div class="col-md-12 ml-sm-auto col-lg-12 pt-3 px-4">
            <center>
                <h2><a class="btn btn-sm btn-primary">所有明星</a></h2>
            </center>
            <div class="table-responsive">
                <table class="table table-striped table-sm">
                    <thead th:replace="~{Commons/commons::showStars}">
                    </thead>
                    <tbody>
                    <tr th:each="stars:${allStars}">
                        <td th:text="${stars.getId()}"></td>
                        <td th:text="${stars.getName()}"></td>
                        <td><img th:src="${stars.getSrc()}" height="85px" width="85px"></td>
                        <td th:text="${stars.getBirth()}"></td>
                        <td th:text="${stars.getJob()}"></td>
                        <td th:text="${stars.getWork()}"></td>
                        <td th:text="${stars.getMes()}"></td>
                        <td>
                            <a class="btn btn-sm btn-success"
                             th:href="@{/stars/toUpdate(id=${stars.getId()})}">修改信息</a>
                            <a class="btn btn-sm btn-danger"
                             th:href="@{/stars/delete(id=${stars.getId()},nowPage=${nowPage})}" onclick="return sureDelete()">删除</a>
                            <br/><br/>

                            <form  method="post" action="/upload" enctype="multipart/form-data">
                                <input type="hidden" name="name" th:value="${stars.getName()}">
                                <input type="hidden" name="nowPage" th:value="${nowPage}">
                                <input type="file" required="required" name="pic" id="pic" >
                                <input  type="submit" class="btn btn-sm btn-danger"
                                        th:value="修改头像" o>
                            </form>
                        </td>
                    </tr>

                    <div class="box">
                        <span>
                            <button  class="btn btn-sm btn-info" th:text="当前用户+${session.nowUser}"></button>
                        </span>
                        <span>
                            <button class="btn btn-sm btn-success" th:text="${updateSrc}"></button>
                        </span>
                    </div>
                    </tbody>
                </table>
                <br/>

                <center>
                    <h2>
                        <a class="btn btn-sm btn-success" th:text="上一页"
                           th:href="@{/stars/toStars/(page=${nowPage}-1)}"></a>
                        <button class="btn btn-sm btn-success" th:text="当前页数+${nowPage+1}"></button>
                        <a class="btn btn-sm btn-success" th:text="下一页"
                           th:href="@{/stars/toStars/(page=${nowPage}+1)}"></a>
                        <button class="btn btn-sm btn-success" th:text="共计页数+${rows}"></button>
                        <br/><br/>
                        <form th:action="@{/stars/toStars}">
                            输入页数：<input type="text" name="page" id="page" required="required" style="height: 35px;width: 50px;">
                            <input  type="submit" class="btn btn-sm btn-info" value="跳转" onclick="reducePage()">
                        </form>
                    </h2>
                </center>
                </center>
            </div>
        </div>
</div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" src="js/jquery-3.2.1.slim.min.js"></script>
<script type="text/javascript" src="js/popper.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>

<!-- Icons -->
<script type="text/javascript" src="js/feather.min.js"></script>
<script>
    feather.replace()
</script>

<!-- Graphs -->
<script type="text/javascript" src="js/Chart.min.js"></script>
<script>
    var pic = document.getElementById("pic2");
    var page = document.getElementById("page");
    function checkPic2() {
        alert(pic.value);
        var picName=pic.value;
        var ext=picName.substring(picName.lastIndexOf("."));
        if(ext==".jpg"||ext==".png"){
        }else {
            alert("请选择jpg和png格式的图片！");
        }

    }
    function reducePage() {
        page.value=page.value-1;
    }
    function sureDelete() {
        if(confirm("确定要删除该信息吗？删除将不能恢复！"))
            return true;
        else
            return false;
    }
    var ctx = document.getElementById("myChart");
    var myChart = new Chart(ctx, {
        type: 'line',
        data: {
            labels: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
            datasets: [{
                data: [15339, 21345, 18483, 24003, 23489, 24092, 12034],
                lineTension: 0,
                backgroundColor: 'transparent',
                borderColor: '#007bff',
                borderWidth: 4,
                pointBackgroundColor: '#007bff'
            }]
        },
        options: {
            scales: {
                yAxes: [{
                    ticks: {
                        beginAtZero: false
                    }
                }]
            },
            legend: {
                display: false,
            }
        }
    });
</script>

</body>

</html>